//主要用于员工工作日志,如:日志标签颜色选择
function findObj(n, d){
    var p,i,x;
    if(!d)d=document;
    if((p=n.indexOf("?"))>0 && parent.frames.length){
        d=parent.frames[n.substring(p+1)].document;
        n=n.substring(0,p);
    }
    if(!(x=d[n]) && d.all)x=d.all[n];
    for(i=0; !x && i<d.forms.length; i++)x=d.forms[i][n];
    for(i=0; !x && d.layers && i<d.layers.length; i++)x=findObj(n,d.layers[i].document);
    if(!x && d.getElementById)x=d.getElementById(n);
    return x;
}
function colorsa(c){
    findObj('colordiv').style.display='none';
    findObj('colortd').style.backgroundColor='#'+c;
//    alert('#'+c); //修改此处可达到其他不同的效果
    document.getElementById("color").value=findObj('colortd').style.backgroundColor;
}
var hexch=new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
function ToHex(n){
    var h, l;
    n=Math.round(n);
    l=n%16;
    h=Math.floor((n / 16)) % 16;
    return (hexch[h]+hexch[l]);
}
function ToHex1(n){
    var l1;
    n=Math.round(n);
    l1=n % 16;
    return (hexch[l1]+hexch[l1]);
}
function wc(r, g, b, n){
    r=((r*16+r)*3*(15 - n)+0x80*n) / 15;
    g=((g*16+g)*3*(15 - n)+0x80*n) / 15;
    b=((b*16+b)*3*(15 - n)+0x80*n) / 15;
    document.write('<td width="8" bgcolor="#'+ToHex(r)+ToHex(g)+ToHex(b)+'" onclick="colorsa(\''+ToHex(r)+ToHex(g)+ToHex(b)+'\');" onmouseover="this.style.backgroundImage=\'url(color_bg.gif)\';" onmouseout="this.style.backgroundImage=\'\';"></td>');
}
var cnum=new Array(1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0);
function colortabl(){
    for(i=0; i < 15; i ++){
        document.write('<table border="0" cellpadding="0" cellspacing="0"><tr>');
        document.write('<td bgcolor="#'+ToHex1(i)+ToHex1(i)+ToHex1(i)+'" height="8" width="8" onclick="colorsa(\''+ToHex1(i)+ToHex1(i)+ToHex1(i)+'\');" onmouseover="this.style.backgroundImage=\'url(color_bg.gif)\';" onmouseout="this.style.backgroundImage=\'\';"></td>')
        for(j=0; j < 30; j ++){
            n1=j % 5;
            n2=Math.floor(j / 5)*3;
            n3=n2+3;
            wc((cnum[n3]*n1+cnum[n2]*(5 - n1)),(cnum[n3+1]*n1+cnum[n2+1]*(5 - n1)),(cnum[n3+2]*n1+cnum[n2+2]*(5 - n1)), i);
        }
        document.writeln('</tr></table>');
    }
}
